package com.hualan.sfzy.service.impl.consult;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.constant.CommonConstant;
import com.hualan.sfzy.mapper.consult.ConsultEvaluateMapper;
import com.hualan.sfzy.model.entity.ConsultEvaluate;
import com.hualan.sfzy.model.vo.ConsultEvaluateVO;
import com.hualan.sfzy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ConsultEvaluateServiceImpl implements BaseService<ConsultEvaluate> {
    @Autowired
    private ConsultEvaluateMapper mapper;
    @Override
    public int add(ConsultEvaluate entity) {
        return mapper.insert(entity);
    }

    // 没有修改评论操作
    @Override
    public int edit(ConsultEvaluate entity) {
        return 0;
    }

    @Override
    public int remove(Integer id) {
        return mapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return mapper.deleteBatch(ids);
    }

    @Override
    public List<ConsultEvaluate> find() {
        return Collections.emptyList();
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, ConsultEvaluate entity) {
        return Collections.emptyMap();
    }

    @Override
    public ConsultEvaluate findById(Integer id) {
        return null;
    }


    public List<ConsultEvaluateVO> findAll() {
        return mapper.selectAll();
    }


    public Map<String, Object> findPagePro(Integer pageNum, Integer pageSize, ConsultEvaluateVO entity) {
        PageHelper.startPage(pageNum, pageSize);
        List<ConsultEvaluateVO> list = mapper.selectPage(entity);
        PageInfo<ConsultEvaluateVO> info = new PageInfo<>(list);
        Map<String, Object> map = new HashMap<>();
        map.put(CommonConstant.PAGE_LIST, list);
        map.put(CommonConstant.PAGE_TOTAL, info.getPages());
        map.put(CommonConstant.TOTAL, info.getTotal());
        return map;
    }


    public List<ConsultEvaluateVO> findByUserId(Integer id) {
        return mapper.selectByUserId(id);
    }
    public List<ConsultEvaluateVO> findByConsultId(Integer id) {
        return mapper.selectByConsultId(id);
    }
}
